package com.kaifamiao.enums;

/**
 * 在编译阶段，编译器会为所有的枚举类型添加的两个类方法:
 * 1、public static ?[] values()
 * 2、public static ? valueOf( String constantName )
 */
public class TestWeekdays {

    public static void main(String[] args) {
        System.out.println( Weekdays.MONDAY );

        Weekdays mon = Weekdays.valueOf( "MONDAY" );
        System.out.println( mon.toString() );

        System.out.println( mon.ordinal() + " , " + mon.name() );

        Weekdays tue = Weekdays.valueOf( "TUESDAY" );
        System.out.println( tue.ordinal() + " , " + tue.name() );

        System.out.println( "- ".repeat( 5 ) );

        Weekdays[] days = Weekdays.values();
        for (int i = 0; i < days.length; i++) {
            Weekdays w = days[i];
            System.out.println( w.toString() + ", " + w.ordinal() + " , " + w.name() );
        }
    }

}
